﻿using System;

/// <summary>
/// Summary description for Class1
/// </summary>
namespace nodelist
{
    public class Node<T>
    {
        public Node<T> Next { get; set; }
        public T Data { get; set; }
        public Node(T t) { Next = null; Data = t; }
    }
    public class List<T>
    {
        private Node<T> head;
        private Node<T> tail;
        public List()
        {
            head = null; tail = null;
        }
        public Node<T> Head { get => head; }
        public void Add(T t)
        {
            Node<T> n = new Node<T>(t);
            if (tail == null)
            {
                head = n; tail = n;
            }
            else
            {
                tail.Next = n;
                tail = n;
            }
        }
        public void ForEach(Action<T> action)
        {
            Node<T> p = this.head;
            while (p != null)
            {
                action(p.Data);
                p = p.Next;
            }
        }

    }
}
namespace pro
{
    class program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            List<int> intList = new List<int>();
            for (int x = 0; x < 10; x++)
            {
                intList.Add(random.Next(0, 10));
            }

            intList.ForEach(it => Console.WriteLine(it));

            int max = int.MinValue;
            int min = int.MaxValue;
            int sum = 0;
            intList.ForEach(it => {
                if (it > max) max = it;
                if (it < min) min = it;
                sum += it;
            });

            Console.WriteLine($"Maximum: {max}");
            Console.WriteLine($"Minimum: {min}");
            Console.WriteLine($"Sum: {sum}");

        }
    }
}